<?php 
/////////////////////////////////////////////////////////////////////////////
// 这个文件是 网城创想多用户商城 项目的一部分
//
// Copyright (c) 2007 - 2008 www.shopnc.net 
//
// 要查看完整的版权信息和许可信息，请查看源代码中附带的 COPYRIGHT 文件，
// 或者访问 http://www.shopnc.net/ 获得详细信息。
/////////////////////////////////////////////////////////////////////////////

/**
 * FILE_NAME : statics_product.manage.php   FILE_PATH : \system\statics_product.manage.php
 * ....商品信息统计
 *
 * @copyright Copyright (c) 2007 - 2007 www.shopnc.net 
 * @author 网城创想多用户商城开发团队 php_netproject@yahoo.com.cn
 * @package 
 * @subpackage 
 * @version Mon Dec 10 16:46:59 CST 2007
 */
require_once("../global.inc.php");

class SysStaticsProduct extends SystemFrameWork{
	/**
	 * 商品对象
	 *
	 * @var obj
	 */
	var $obj_product;
	/**
	 * 验证对象
	 *
	 * @var obj
	 */
	var $objvalidate;
	/**
	 * 会员对象
	 *
	 * @var obj
	 */
	var $obj_member;
	/**
	 * 商品分类对象
	 *
	 * @var obj
	 */
	var $objProductCate;


	function main(){
		/**
		 * 创建商品对象
		 */
		if (!is_object($this->obj_product)){
			require_once("product.class.php");
			$this->obj_product = new ProductClass();
		}
		/**
		 * 创建验证对象
		 */
		if (!is_object($this->objvalidate)){
			require_once("commonvalidate.class.php");
			$this->objvalidate = new CommonValidate();
		}

		/**
		 * 设置模板路径
		 */
		$this->setsubtemplates("system");

		/**
		 * 语言包
		 */
		$this->getlang("product");

		switch ($this->_input['action']){
			case "list":
				$this->_liststatics();
				break;
			default:
				$this->_liststatics();
				break;
		}

	}
	/**
	 * 商品统计信息
	 *
	 */
	function _liststatics(){

		/**
		 * 创建会员对象
		 */
		if (!is_object($this->obj_member)){
			require_once("member.class.php");
			$this->obj_member = new MemberClass();
		}
		/**
		 * 创建商品分类对象
		 */
		if (!is_object($this->objProductCate)){
			require_once ("productclass.class.php");
			$this->objProductCate = new ProductCategoryClass();
		}
		/**
		 * 取得查询参数
		 */
		$obj_condition[keygenre] = $this->_input['searchtype'];
		$obj_condition[state] = 1;/*商品状态，1发布*/
		
		$obj_condition[key] = $this->_input['keyword'];
		if("" != $this->_input['pcid']){
			$obj_condition[search_cate] = $this->_input['pcid'];
		}else{
			$obj_condition[search_cate] = $this->_input['searchcate'];
		}
		$obj_condition[havetime] = 1;
		$obj_condition[keygenre] = $this->_input['searchtype'];
		$obj_condition[price_min] = $this->_input['price_min'];
		$obj_condition[price_max] = $this->_input['price_max'];
		if ($this->_input['sell_type'] != 'all'){
			$obj_condition[sell_type] = $this->_input['sell_type'];
		}
		$obj_condition[p_type] = $this->_input['p_type'];
		$obj_condition[search_place] = $this->_input['search_place'];
		$obj_condition[tf_charge] = $this->_input['tf_charge'];
		$obj_condition[type] = $this->_input['type'];
		$obj_condition[end_time] = $this->_input['end_time'];
		$obj_condition[member] = $this->_input['member'];

		if ($this->_input['order'] == ""){
			$obj_condition[order] = 1;
		}else{
			$obj_condition[order] = $this->_input['order'];
		}
		if ($this->_input['sorttype'] == ""){
			$obj_condition[sorttype] = 1;
		}else{
			$obj_condition[sorttype] = $this->_input['sorttype'];
		}
		/**
		 * 取得商品统计列表
		 */
		$row_nums = 10;
		$product_array = $this->obj_product->getStaticsProduct($condition, $row_nums);
		$product_total = 0;
		foreach($product_array as $key => $value){
			$product_total += $value['num'];
			$product_cate = $this->objProductCate->getPcateRow($value['pc_id']);
			$product_array[$key]['pc_name'] = $product_cate[0]['name'];
		}
		
		/**
		 * 输出到页面模板
		 */
		$this->output("product_array", $product_array);
		$this->output("product_total", $product_total);
		$this->showpage("sys_statics_product.manage");
	}
}

$statics_product = new SysStaticsProduct();
$statics_product->main();
unset($statics_product);
?>